<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <link rel="shortcut icon" href="./images/logo.png" type="image/x-icon"/>
    <title>SWCRM_KM</title>
    <style type="text/css">
    html,
    body {
      margin: 0px;
      height: 100%;
    }


    </style>
    <script>

        var loginname = "";
        var key = "";
        var q = "";

        function getQueryString(name) {
            let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
            let r = window.location.search.substr(1).match(reg);
            if (r != null) {
                return decodeURIComponent(r[2]);
            };
            return null;
        }

        // 初始化
        function loadURL() {
            console.log('初始化加载中...');
            var isGoon = true;

            if (isGoon) {
                loginname = decodeURIComponent(getQueryString("loginname"));
                loginname = loginname=="null"?"SzwgCallcenter":loginname;
                key = decodeURIComponent(getQueryString("key"));
                key = key=="null"?"V5_FQLPPPIYVADMIN":key;
                q = decodeURIComponent(getQueryString("q"));
                console.log('调用参数信息-loginname:' + loginname + ' key:' + key + ' q:' + q);

                // 获取问号后所有的字符串
                var interURL = "http://138.0.0.65:8020/elitewgservice/api/callRedirect?key=${key}&loginname=${loginname}&url=http://138.0.0.65:8020/kbs/sso/login".replace("${loginname}", loginname).replace("${key}", key);
                console.log('调用参数信息-interURL:' + interURL);

                document.getElementById("reportFrame").src = interURL;

            } else {
                if (navigator.userAgent.indexOf("Firefox") != -1 || navigator.userAgent.indexOf("Chrome") != -1) {
                    open(location, '_self').close();
                    window.location.href = "404.html";
                    window.close();
                } else {
                    window.opener = null;
                    window.open("", "_self");
                    window.close();
                    open(location, '_self').close();
                }
            }

            console.log('初始化加载结束');
        }

        window.loaded = false;
        window.name = "main";

        function initialize() {
            if (window.loaded) {
                console.log('Iframe加载结束');
            } else {
                setTimeout(function () {
                    console.log("Do this instead");
                    // document.getElementById("reportFrame").src = "http://138.0.0.65/kbs/search?type=true&st=TYPE_FULLTEXT&q=" + q;
                    window.location = "http://138.0.0.65/kbs/search?type=true&st=TYPE_FULLTEXT&q=" + q;
                }, 500);
                window.loaded = true;
            };

        }
    </script>
</head>

<body onload="loadURL()">
<div style="width: 100%; height: 100%; display: flex; flex-flow: column; position: relative;">
    <div style="flex: 1 1 0%; position: relative; height: 0px;"></div>
    <div style="height: 100%; display: flex; position: relative; min-height: 600px;">
        <div style="flex: 1 1 0%; position: relative; width: 0px;"></div>
        <div
                style="width: 100%; min-width: 1000px; min-height: 600px; position: relative;box-shadow: 0 0 24px 0 rgb(15 66 76 / 25%)">
            <iframe id="reportFrame"
                    style="width: 100%; height: 100%; position: relative; display: block; border-width: 0px;" name="reportFrame"
                    frameBorder=0 scrolling=no width="100%" onload="initialize()" sandbox="allow-same-origin allow-scripts allow-forms allow-popups allow-modals allow-popups-to-escape-sandbox allow-top-navigation"></iframe>
        </div>
        <div style="flex: 1 1 0%; position: relative; width: 0px;"></div>
    </div>
    <div style="flex: 1 1 0%; position: relative; height: 0px;"></div>
</div>
</body>

</html>